import React from 'react'
import ReactDOM from 'react-dom'

class Toggle extends React.Component {
  constructor() {
    super()
    this.state = { isToggleOn: true }
    this.handleClick = this.handleClick.bind(this)
  }

  handleClick () {
    this.setState(state => ({
      isToggleOn: !state.isToggleOn
    }))
  }

  render () {
    return (
      <button onClick={this.handleClick}>
        {this.state.isToggleOn ? 'ON' : 'OFF'}
      </button>
    );
  }
}


ReactDOM.render(<Toggle></Toggle>, document.getElementById('root'))
